<!--
programe:
    js 动态改变html 元素的属性
history:
    2014-9-26  liuxu frist release
-->
<!DOCTYPE html>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script>

    
    function changeElementProperty(){
        element = document.getElementById("myimage");
        
        src = element.src.match("bulbon");
        if(src){
            element.src="images/pic_bulboff.gif";
            document.getElementById("switch").innerHTML = "开灯";
        }else{
            element.src="images/pic_bulbon.gif";
            document.getElementById("switch").innerHTML = "关灯";
        }

    }

</script>

</head>
<body>
    <img id="myimage" src="images/pic_bulboff.gif" width="100" height="180">
    <button id="switch" type="button"  onclick="changeElementProperty()">开灯</button>
</body>
</html> 


	
